define(['angular', 'store'], function (angular, store) {
    "use strict";

    var factory = function ($location, $http, $q, $sce, WT_BASE_PATH, WZ_BASE_PATH, CommonService) {
        return {
            getQuestions: function (client_id) {
                return CommonService.ajax({
                    url: '/xdb/risk/showRiskPaper',
                    type: 'get',
                    data: {
                        paper_type: 'l',
                        exam_type: 2,
                        client_id: client_id
                    }
                });
            },
            getAgreements:function(data){
                return CommonService.ajax({
                    url: '/xdb/openPer/elecSign',
                    type: 'get',
                    data: {
                        fund_account: data.fund_account,
                        client_id: data.client_id
                    }
                });
            },
            setAnswer: function (data) {
                return CommonService.ajax({
                    url: '/xdb/risk/submit',
                    data: {
                        paper_type: 'l',
                        exam_type: 2,
                        client_id: data.client_id,
                        answers: data.answers
                    }
                });
            },
            setCreditQuota:function(client_id){
                return CommonService.ajax({
                    url: '/xdb/risk/setStockPledgeAmount',
                    data: {
                        paper_type: 'l',
                        client_id: client_id,
                        credit_quota: 3000000
                    }
                });
            },
            setUserEmail: function (data) {
                return CommonService.ajax({
                    url: '/xdb/ajaxVerify/updateUserEmail',
                    data: {
                        paper_type: 1,
                        exam_type: 2,
                        client_id: {
                            client_id: data.client_id,
                            fund_account: data.fund_account,
                            e_mail: data.e_mail
                        }
                    }
                });
            },
            setAgreement:function(data){
                return CommonService.ajax({
                    url: '/xdb/openPer/signAgreement',
                    data: {
                            client_id: data.client_id,
                            fund_account: data.fund_account,
                            signValue:data.signValue,
                            cert_sn:'sn'
                    }
                });
            },
            addUser:function(data){
                return CommonService.ajax({
                    url: '/xdb/openPer/addPermission',
                    data: {
                            client_id: data.client_id,
                            fund_account: data.fund_account
                    }
                });
            },
            getIndexInfo:function(data){
                return CommonService.ajax({
                    url: '/xdb/index',
                    data: {
                        client_id: data.client_id,
                        fund_account: data.fund_account
                    }
                });
            },
            //权限管理
            getUserAuthInfo:function(data){
                return CommonService.ajax({
                    url: '/xdb/auth/show',
                    data: {
                        client_id: data.client_id
                    }
                });
            },
            //我要还款
            getRepaymentIndexInfo:function(data){
                return CommonService.ajax({
                    url: '/xdb/repayment/repaymentIndex',
                    data: {
                        client_id: data.client_id,
                        title_id:data.title_id
                    }
                });
            }
        }
    };

    factory.$inject = ['$location', '$http', '$q', '$sce', 'WT_BASE_PATH', 'WZ_BASE_PATH', 'CommonService'];
    return factory;
});